<template>
  <div class="m-user">
    <template v-if="username && token">
      欢迎您，<span class="username">{{ username }}</span>
      <nuxt-link to="/login" style="cursor:pointer; color:#13D1BE">退出</nuxt-link>
      <!-- <span @click="logout" style="cursor:pointer; color:#13D1BE">退出</span> -->
    </template>
    <template v-else>
      <nuxt-link to="/login" class="login">立即登录</nuxt-link>
      <nuxt-link to="/register" class="register">注册</nuxt-link>
    </template>
  </div>
</template>

<script>
export default {
  computed: {
    username(){
      return this.$store.state.user.username 
    },
    token(){
      return this.$store.state.user.token 
    }
  }
};
</script>
